const articleControllers = require('../../controller/app/article');
const {getIp} = require('../../assets/util');

exports.getArticleDetail = (req, res) => {
    let ip = getIp(req);
    let paramsJson = {
        articleId: req.body.articleId,
        ip
    }
    articleControllers.getArticleDetail(paramsJson, e => {
        res.status(200).json(e);
    })
}

exports.searchArticle = (req, res) => {
    articleControllers.searchArticle(req.body, e => {
        res.status(200).json(e);
    })
}

exports.searchArticleForType = (req, res) => {
    let ip = getIp(req);
    let params = req.body;
    let paramsJson = {
        type: params.type,
        pageSize: params.pageSize ? Number(params.pageSize) : 10,
        pageNum: params.pageNum ? Number(params.pageNum) : 1,
        ip
    }
    articleControllers.searchArticleForType(paramsJson, e => {
        res.status(200).json(e);
    })
}

exports.articlesLikes = (req, res) => {
    let ip = getIp(req);
    let paramsJson = {
        articleId: req.body.articleId,
        ip
    }
    console.log(paramsJson);
    articleControllers.articlesLikes(paramsJson, e => {
        res.status(200).json(e);
    });
}